<template>
  <div>
    <el-row>
      <el-col >
    <el-form ref="form" :model="form" :inline="true" style="text-align: left;height: 38px">
    <!--   <el-form-item>
        <el-input v-model="form.filter.kwd" style="float: left;" placeholder="请输入受试者号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" style="float: left;" @click.native="onSubmit"><i class="el-icon-search"></i>查询
        </el-button>
      </el-form-item> -->
      <el-form-item>
        <el-button v-if="$utils.ckUIPower('S01010101')&&currentStatus==1" @click="changeSubjectActives"
                   style="float: left;"  :disabled="zufen">
                   <!-- :disabled="editClick" -->
          批量分组
        </el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" style="float: left;" @click.native="viewClick" :disabled="fenzu">分组视图
        </el-button>
      </el-form-item>
      <el-form-item>
        周期选择
        <el-select v-model="cycleSee" placeholder="请选择" style="width:110px;padding:1px;margin:0 5px;" @change="dicTransfor()">
                      <el-option
                        v-for="item in cycleSelection"
                        :key="item"
                        :label="item"
                        :value="item"
                        >
                      </el-option>
                    </el-select>
      </el-form-item>
      
    </el-form>
    </el-col>

   <!--  <el-col :span="8">
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page.pageNumber"
          :page-sizes="[10, 20, 30]"
          :page-size="10"
          layout="total, prev, pager, next, jumper"
          :total="page.totalRow">
        </el-pagination>
      </div>
    </el-col> -->
    </el-row>
    <div>
      <el-table stripe
                v-loading="loading"
                element-loading-text="数据加载中"
                :data="page"
                style="width:100%"
                @sort-change="onSubmit"
                @selection-change="handleSelectionChange"
                border>
        <el-table-column
          inline-template
          fixed
          label="序号"
          width="80px"
          align="center">
          <span>{{$index + 1 }}</span>
        </el-table-column>
        <!--<el-table-column-->
          <!--property="num"-->
          <!--fixed-->
          <!--sortable="custom"-->
          <!--label="受试者号"-->
          <!--width="120px"-->
          <!--align="center">-->
        <!--</el-table-column>-->

        <el-table-column
          type="selection"
          width="55">
        </el-table-column>

        
        <el-table-column
          label="随机号"
          property="random_num"
          sortable="custom"
          
          align="center">
        </el-table-column>
        <el-table-column
          label="姓名"
          property="name"
          sortable="custom"
         
          align="center">
        </el-table-column>
        <el-table-column
          property="oper"
          sortable="custom"
          label="管理人员"
          
          align="center">
        </el-table-column>
        <el-table-column
          label="组号"
          property="gro"
          sortable="custom"
         
          align="center">
        </el-table-column>
        
        <el-table-column
          property="cycles"
          sortable="custom"
          label="周期"
          
          align="center">
        </el-table-column>
        
        <el-table-column
            fixed="right"
            label="脱落操作"
            width="100">
            <template slot-scope="scope">

              <el-button     v-if='scope.row.drop==1||scope.row.drop==null' type="text" @click.native="fallOff(scope.row.id)">脱落</el-button>
              <p  v-if='scope.row.drop==2' class="reds">
                已脱落
              </p>
            </template>
           <!--  <template slot-scope="scope" v-if='scope.row.drop==2'>
              
            </template> -->

          </el-table-column>
        
      </el-table>
    </div>
    
    <el-dialog
      title="批量分组"
      :visible.sync="batchgrouping"
      width="30%"
      :before-close="handleClose">
                <div class="Fzu">组号
                     <el-select v-model="group" placeholder="请选择" >
                      <el-option
                        v-for="item in grouparr"
                        :key="item"
                        :label="item"
                        :value="item"
                        >
                        
                      </el-option>
                    </el-select>
                  <!-- <el-input v-model="group" style="width:40px;padding:1px;margin:0 5px;" ></el-input> -->
                </div>
                 <div class="Fzu">周期
                  
                  <el-select v-model="cycle" placeholder="请选择" style="width:60px;padding:1px;margin:0 5px;" @change="cycBian">
                      <el-option
                        v-for="cycleArrs in cycleArr"
                        :key="cycleArrs"
                        :label="cycleArrs"
                        :value="cycleArrs"
                        >
                        
                      </el-option>
                    </el-select>
                </div>
                
                <div  class="Fzu">时间间隔
                  <el-input v-model="timeInterval" style="width:50px;padding:1px;margin:0 5px;"></el-input>秒
                </div>
                <div >
                服药类别
                  <el-input v-model="drugClass"style="width:50px;padding:1px;margin:0 5px;"></el-input>
                </div>
                 <div class="sstime">
                    计划开始节点
                  
                  <el-select v-model="point"  placeholder="请选择" style="width:140px;padding:1px;margin:0 5px;" >
                      <el-option
                        v-for="pointArrS in pointArr"
                        :key="pointArrS.sort_no"
                        :label="pointArrS.name"
                        :value="pointArrS.sort_no"
                        >
                        
                      </el-option>
                    </el-select>
                      
                   
                </div>
                <div class="guanli">
                    
                      <span class="demonstration">计划开始时间</span>
                      <el-date-picker
                        v-model="times"
                        type="datetime"
                        @change="getTime"
                        placeholder="选择日期时间"
                        >
                      </el-date-picker>
                   
                </div>
            <div class="guanli">操作人员
                   <el-select
                      v-model="Arr2ren"
                      multiple
                      filterable
                      allow-create
                      default-first-option
                      placeholder="请选择"  style="width:250px;padding:1px;margin:0 5px;" >
                      <el-option
                        v-for="adminisArrS in adminisArr"
                        :key="adminisArrS.id"
                        :label="adminisArrS.name"
                        :value="adminisArrS.id">
                      </el-option>
                    </el-select>
                  <!-- <el-select v-model="adminis"  placeholder="请选择" style="width:100px;padding:1px;margin:0 5px;" >
                      <el-option
                        v-for="adminisArrS in adminisArr"
                        :key="adminisArrS.name"
                        :label="adminisArrS.name"
                        :value="adminisArrS.name"
                        >
                        
                      </el-option>
                    </el-select> -->
                </div>
          <span slot="footer" class="dialog-footer" style="margin-right:20px; ">
            <el-button type="primary" @click="packetsub()">确 定</el-button>
          </span>
          <span slot="footer" class="dialog-footer" >
            <el-button type="primary" @click="colsess()">关 闭</el-button>
          </span>
    </el-dialog>
    <el-dialog
      title="脱落原因"
      :visible.sync="causefalling"
      width="40%"
      :before-close="causefallingcols">
          <div class="usefal2">
           {{causefallingUnknown}}
          </div>
          <div class="usefal">脱落周期：
                  <el-select v-model="causefallcycle" placeholder="请选择" style="width:100px;padding:1px;margin:0 5px;" >
                      <el-option
                        v-for="item in causefallingArr"
                        :key="item"
                        :label="item"
                        :value="item"
                        >
                      </el-option>
                  </el-select>
              <span class="demonstration">脱落时间</span>
                <el-date-picker
                  v-model="causetime"
                  type="datetime"
                  @change="getTime"
                  placeholder="选择日期时间"  class="thistime">
                </el-date-picker>
          </div>
          <div class="">
            <el-input v-model="falling" type="textarea"  style="margin:10px 0;"  placeholder="请输入脱落原因"></el-input>
          </div>
          <span slot="footer" class="dialog-footer" style="margin-right:20px;">
            <el-button type="primary" @click="causesub()">确 定</el-button>
          </span>
          <span slot="footer" class="dialog-footer" >
            <el-button type="primary" @click="causefallingcols()">关 闭</el-button>
          </span>
    </el-dialog>

    <el-dialog
      title="分组视图"
      :visible.sync="upView"
      class="upVVV"
      :before-close="upViewClose">
                <div class="Fzu fzuss" >
                组号
                     <el-select v-model="group2" placeholder="请选择" style="width:60px;padding:1px;margin:0 5px;" @change="chooseMedicine()">
                      <el-option
                        v-for="item in grouparr2"
                        :key="item"
                        :label="item"
                        :value="item"
                        >
                      </el-option>
                    </el-select>
                    时间类型
                     <el-select v-model="timeA" placeholder="请选择" style="width:160px;padding:1px;margin:0 5px;"  @change="SYSY()">
                      <el-option
                        :key="planning"
                        :label="timeJ"
                        :value="planning"
                        >
                      </el-option>
                      <el-option
                        :key="theory"
                        :label="timeL"
                        :value="theory"
                        >
                      </el-option>
                    </el-select>
                    <span>
                      周期：{{cycleSee}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </span>
                    <span>
                      操作人员：{{userName}}
                    </span>
                </div>

                  <el-button type="primary" style="float: right;" @click="printing()">打印
                  </el-button>
               
              <el-table
                :data="tableData"
                border
                >
                <el-table-column 
                  fixed
                  prop="0"
                  label=''
                  width="150"
                  v-if="leng1">
                </el-table-column>
                <el-table-column
                  prop="1"
                  label=""
                  width="200"
                  v-if="leng2"
                 >
                </el-table-column>
                <el-table-column
                  prop="2"
                  label=""
                  width="200"
                  v-if="leng3"
                 >
                </el-table-column>
                <el-table-column
                  prop="3"
                  label=""
                  width="200"
                   v-if="leng4"
                  >
                </el-table-column>
                <el-table-column
                  prop="4"
                  label=""
                  width="200"
                   v-if="leng5"
                  >
                </el-table-column>
                <el-table-column
                  prop="5"
                  label=""
                  width="200"
                   v-if="leng6"
                 >
                </el-table-column>
                <el-table-column
                  prop="6"
                  label=""
                  width="200"
                   v-if="leng7"
                 >
                </el-table-column>
                <el-table-column
                  prop="7"
                  label=""
                  width="200"
                   v-if="leng8"
                 >
                </el-table-column>
                <el-table-column
                  prop="8"
                  label=""
                  width="200"
                   v-if="leng9"
                 >
                </el-table-column>
                <el-table-column
                  prop="9"
                  label=""
                  width="200"
                   v-if="leng10"
                 >
                </el-table-column>
                <el-table-column
                  prop="10"
                  label=""
                  width="200"
                  v-if="leng11"
                  >
                </el-table-column>
                


              
              </el-table>
                  <!-- <el-input v-model="group" style="width:40px;padding:1px;margin:0 5px;" ></el-input> -->
                
          
          <!-- <span slot="footer" class="dialog-footer" style="margin-right:20px;">
            <el-button type="primary" @click="packetsub()">打 印</el-button>
          </span>
          <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="colsess()">关 闭</el-button>
          </span> -->
          <div style="clear: both"></div>
            <div id="printTarget" v-show="false" style="width: 100%;">
              <h4 style="text-align: center">时间计划表</h4>
              <!-- <div v-if="projectInformation!=null&&projectInformation!=undefined"> -->
              <div>
                 周期：{{cycleSee}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;组号：{{group2}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                   
                    
                      操作人员：{{userName}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;时间类型：{{timeALL[timeA]}}
              </div>
                <table style="width: 100%;border-collapse: collapse;font-size: 15px">
                   
                    <tbody>
                        <tr v-for="item in itmeList" style="border: 1px solid #000">
                      <td align="center" style="border-right: 1px solid #000;" v-if="leng1">{{item[0]}}</td>
                      
                      <td align="center" style="border-right: 1px solid #000;" v-if="leng2">
                        {{item[1]}}
                      </td>
                      <td align="center" style="border-right: 1px solid #000;" v-if="leng3">{{item[2]}}</td>
                      <td align="center" style="border-right: 1px solid #000;" v-if="leng4">
                        {{item[3]}}
                      </td>
                      <td align="center" v-if="leng5" style="border-right: 1px solid #000;">{{item[4]}}</td>
                      <td align="center" v-if="leng6" style="border-right: 1px solid #000;">{{item[5]}}</td>
                      <td align="center" v-if="leng7" style="border-right: 1px solid #000;">{{item[6]}}</td>
                      <td align="center" v-if="leng8" style="border-right: 1px solid #000;">{{item[7]}}</td>
                      <td align="center" v-if="leng9" style="border-right: 1px solid #000;">{{item[8]}}</td>
                      <td align="center" v-if="leng10" style="border-right: 1px solid #000;">{{item[9]}}</td>
                      <td align="center" v-if="leng11" style="border-right: 1px solid #000;">{{item[10]}}</td>

                    </tr>
                    </tbody>
                   
                </table>
              <!-- </div> -->
            </div>
    </el-dialog>
    <!--<div class="block">-->
      <!--<el-pagination-->
        <!--@size-change="handleSizeChange"-->
        <!--@current-change="handleCurrentChange"-->
        <!--:current-page="page.pageNumber"-->
        <!--:page-sizes="[10, 20, 30]"-->
        <!--:page-size="10"-->
        <!--layout="total, prev, pager, next, jumper"-->
        <!--:total="page.totalRow">-->
      <!--</el-pagination>-->
    <!--</div>-->
    
    <!--标签弹框-->
 <!--    <tag-dialog :tag-dialog-visible="tagDialog.show" @closeTagDialog="closeTagDialog" :subject-id="subjectId"
                :subject-num="subjectNum"></tag-dialog>
     -->
    
  </div>
</template>
<script>
  // import EditDialog from './edit.dialog.vue'
  // import RegisterDialog from './register.dialog.vue'
  // import TagDialog from './tag.dialog.vue'
  // import TimeDialog from './time.dialog.vue'
  import http from '../../../api/http'
  export default {
    data () {
      var model = {testStatus:0};
      return {
        causetime:'',//脱落时间
        causefalling:false,//脱落div
        causefallingID:'',//脱落id
        causefallingUnknown:'',//脱落存在位置
        causefallingArr:[],//脱落周期数组
        causefallcycle:'',//脱落周期
        falling:'',//脱落原因
        id:null,
        tableData:[],
        oper:'脱落',
        ids:[],
        group:'',
        grouparr:[],
        group2:1,
        grouparr2:[],
        times: null,
        timeInterval:"",
        cycle:"",
        cycleArr:[],
        adminis:'',
        adminisArr:[],
        adminisid:[],
        loading: true,
        upView:false,
        pjcID:"",
        form: {
          filter: {kwd: '', sort: {create_datetime: 'desc'}},
          pageNo: 1,
          pageSize: 10
        },
        status: ["", ""],
        active: ["禁用", "启用"],
        id: null,
        subjectId: null,
        subjectNum: null,
        dialogData: {show: false},
        editDialog: {show: false},
        registerDialog: {show: false},
        tagDialog: {show: false},
        timeDialog: {show: false},
        // dialogVisiblesf: false,//
        // dialogVisiblesx: false,//
        afbeData:{},
        batchgrouping:false,
        seeLabId:'',
        visitDialog:{show:false},
        numDialog:{show:false},
        page: [],
        currentSubjectId: '',
        currentFinger:'',
        timeList: [],
        projectId:null,
        currentStatus:null,
        sex:null,
        subTime:null,
        name:null,
        multipleSelection: [],
        leng1:false,
        leng2:false,
        leng3:false,
        leng4:false,
        leng5:false,
        leng6:false,
        leng7:false,
        leng8:false,
        leng9:false,
        leng10:false,
        leng11:false,
        timeJ:"计划时间",
        timeL:"理论时间",
        theory:"theory",//理论
        planning:"planning",//计划
        timeA:"planning",
        timeALL:{
          "planning":"计划时间",
          "theory":"理论时间"
        },
        pointArr:[],
        point:"",
        itmeList:[],
        userName:'',
        cycleSee:'筛选池',
        cycleSelection:[],
        fenzu:true,
        zufen:false,
        Arr2ren:[],
        drugClass:'',


      }
    },
    computed: {},
    methods: {
      colsess(){

        var vm=this;
        // console.log(vm.adminis)
        vm.batchgrouping=false;
        vm.group='';
        vm.grouparr=[];
        vm.times=null;
        vm.timeInterval="";
        vm.cycle="";
        vm.pjcID="";
        vm.drugClass="";
        vm.cycleArr=[];
        vm.adminis='';
        vm.adminisArr=[];
        vm.adminisid=[];
       vm.pointArr=[];
       vm.Arr2ren=[];

      vm.point='';
        // console.log(vm.adminisid[vm.adminis])
      },
      getTime(date){
        this.times = date;
        this.causetime = date;
      },
      handleClose(done) {
        
            var vm=this;
            vm.batchgrouping=false;
            vm.group='';
            vm.grouparr=[];
            vm.times=null;
        vm.timeInterval="";
        vm.pjcID="";
        vm.cycle="";
        vm.drugClass="";
        vm.cycleArr=[];
        vm.adminis='';
        vm.adminisArr=[];
        vm.adminisid=[];
        vm.pointArr=[];
         vm.Arr2ren=[];
                vm.point='';
      },
      //打印关闭
      upViewClose(){
          var vm= this;
        vm.upView=false;
        vm.group2=1;
        vm.grouparr2=[];
      },
      //计划时间&理论时间  下拉变化函数
      SYSY(){
        
        
         var vm = this;
         http.postData(vm, '/pt/subjectsGroup/plantable2', {projectId:vm.pjcID,group:vm.group2,type:vm.timeA,cycles:vm.cycleSee}, function (resp) {
            let ret = resp.body;
            // console.log(resp)
              if(ret.code == '111'){
                vm.leng1=true;
                  vm.leng2=true;
                  vm.leng3=true;
                vm.leng4=false;
                vm.leng5=false;
                vm.leng6=false;
                vm.leng7=false;
                vm.leng8=false;
                vm.leng9=false;
                vm.leng10=false;
                vm.leng11=false;
                vm.upView=true;
                vm.tableData=ret.value;
                let lengTH=ret.value[0].length;
               if(lengTH==4){
                  
                  vm.leng4=true;
               }else if(lengTH==5){
                vm.leng4=true;
                vm.leng5=true;
               }else if(lengTH==6){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
               }else if(lengTH==7){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
               }else if(lengTH==8){
                 vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
               }else if(lengTH==9){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
                vm.leng9=true;
               }else if(lengTH==10){
                  vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
                vm.leng9=true;
                vm.leng10=true;
               }else if(lengTH==11){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
                vm.leng9=true;
                vm.leng10=true;
                vm.leng11=true;
               }



                  
                
                
                
              }else{
                vm.$message.error({message:ret.msg});
                vm.leng1=false;
                vm.leng2=false;
                vm.leng3=false;
                vm.leng4=false;
                vm.leng5=false;
                vm.leng6=false;
                vm.leng7=false;
                vm.leng8=false;
                vm.leng9=false;
                vm.leng10=false;
                vm.leng11=false;
              }
            
          
          });
      },
      //批量修改筛选者状态
      changeSubjectActives() {
        var vm = this;
         vm.pointArr=[];
        if (vm.multipleSelection.length) {
            vm.batchgrouping=true;
            vm.pjcID=this.$utils.getCurrenrProject().id;
            // console.log(this.$utils.getCurrenrProject().id)



         
            
            if (vm.multipleSelection != null && vm.multipleSelection.length > 0) {
             
              vm.ids = new Array();
              vm.multipleSelection.forEach(function (o) {
                vm.ids.push(o.id);
              });
              http.postData(vm, '/pt/subjectsGroup/getInfo/' + vm.pjcID, {}, function (resp) {
                var ret = resp.body;
                // console.log(resp)
                if(ret.code == '111'){
                  vm.cycleArr=ret.value.cycles;
                  vm.grouparr=ret.value.group;
                  // vm.pointArr=ret.value.process;
                  vm.adminisArr=ret.value.user;
                  for(var temp in ret.value.user){
                      var ID=ret.value.user[temp].id;
                      var NAME=ret.value.user[temp].name;
                      vm.adminisid[NAME]=ID;
                  }
                  
                  
                  // console.log(vm.adminisid[])
                  // vm.$message.success({message:ret.msg});
                  // vm.onSubmit();
                }else{
                  // vm.$message.error({message:ret.msg});
                }
                // 执行清空操作
                // vm.$refs.multipleTable.clearSelection();
              });
            }
          
        } else {
          vm.$message.error('没有勾选项,请确认您的选择')
        }
      },
      // 视图点击事件
      viewClick(){
        var vm= this;
        vm.pjcID=this.$utils.getCurrenrProject().id;
        http.postData(vm, '/pt/subjectsGroup/getInfo/' + vm.pjcID, {}, function (resp) {
              let ret = resp.body;
              console.log(resp)
                if(ret.code == '111'){
                  vm.grouparr2=ret.value.group;
               
                  
                  http.postData(vm, '/pt/subjectsGroup/plantable2', {projectId:vm.pjcID,group:vm.group2,type:vm.timeA,cycles:vm.cycleSee}, function (resp) {
                      let ret = resp.body;
                      console.log(resp)
                       vm.userName=ret.msg;
                        if(ret.code == '111'){
                          vm.leng1=true;
                          vm.leng2=false;
                          vm.leng3=false;
                          vm.leng4=false;
                          vm.leng5=false;
                          vm.leng6=false;
                          vm.leng7=false;
                          vm.leng8=false;
                          vm.leng9=false;
                          vm.leng10=false;
                          vm.leng11=false;
                          vm.upView=true;
                          vm.tableData=ret.value;
                          let lengTH=ret.value[0].length;
                         if(lengTH==2){
                          vm.leng2=true;
                         }else if(lengTH==3){
                          vm.leng2=true;

                          vm.leng3=true;
                         }else if(lengTH==4){

                          vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                         }else if(lengTH==5){
                          vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                          vm.leng5=true;
                         }else if(lengTH==6){
                          vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                          vm.leng5=true;
                          vm.leng6=true;
                         }else if(lengTH==7){
                           vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                          vm.leng5=true;
                          vm.leng6=true;
                          vm.leng7=true;
                         }else if(lengTH==8){
                           vm.leng2=true;
                          vm.leng3=true;
                           vm.leng4=true;
                          vm.leng5=true;
                          vm.leng6=true;
                          vm.leng7=true;
                          vm.leng8=true;
                         }else if(lengTH==9){
                           vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                          vm.leng5=true;
                          vm.leng6=true;
                          vm.leng7=true;
                          vm.leng8=true;
                          vm.leng9=true;
                         }else if(lengTH==10){
                          vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                          vm.leng5=true;
                          vm.leng6=true;
                          vm.leng7=true;
                          vm.leng8=true;
                          vm.leng9=true;
                          vm.leng10=true;
                         }else if(lengTH==11){
                           vm.leng2=true;
                          vm.leng3=true;
                          vm.leng4=true;
                          vm.leng5=true;
                          vm.leng6=true;
                          vm.leng7=true;
                          vm.leng8=true;
                          vm.leng9=true;
                          vm.leng10=true;
                          vm.leng11=true;
                         }



                            
                          
                          
                          
                        }else{
                          vm.$message.error({message:ret.msg});
                          vm.leng1=false;
                          vm.leng2=false;
                          vm.leng3=false;
                          vm.leng4=false;
                          vm.leng5=false;
                          vm.leng6=false;
                          vm.leng7=false;
                          vm.leng8=false;
                          vm.leng9=false;
                          vm.leng10=false;
                          vm.leng11=false;
                        }
                      
                    
                    });
                }else{
                  vm.$message.error({message:ret.msg});
                }
            
            });
        
      },
      //下拉表格change事件
      chooseMedicine(){
        var vm =this;
        // console.log(vm.group2)
        http.postData(vm, '/pt/subjectsGroup/plantable2', {projectId:vm.pjcID,group:vm.group2,type:vm.timeA,cycles:vm.cycleSee}, function (resp) {
              var ret = resp.body;
              vm.userName=ret.msg;
              // console.log(resp)
                if(ret.code == '111'){
                 vm.upView=true;
                 vm.leng1=true;
                  vm.leng2=false;
                  vm.leng3=false;
                  vm.leng4=false;
                  vm.leng5=false;
                  vm.leng6=false;
                  vm.leng7=false;
                  vm.leng8=false;
                  vm.leng9=false;
                  vm.leng10=false;
                  vm.leng11=false;
                  vm.tableData=ret.value;
                  let lengTH=ret.value[0].length;
                 if(lengTH==2){
                    vm.leng2=true;
                   }else if(lengTH==3){
                    vm.leng2=true;

                    vm.leng3=true;
                   }else if(lengTH==4){

                    vm.leng2=true;
                    vm.leng3=true;
                    vm.leng4=true;
                   }else if(lengTH==5){
                    vm.leng2=true;
                    vm.leng3=true;
                    vm.leng4=true;
                    vm.leng5=true;
                   }else if(lengTH==6){
                     vm.leng2=true;
                    vm.leng3=true;
                    vm.leng4=true;
                    vm.leng5=true;
                    vm.leng6=true;
                   }else if(lengTH==7){
                     vm.leng2=true;
                    vm.leng3=true;
                    vm.leng4=true;
                    vm.leng5=true;
                    vm.leng6=true;
                    vm.leng7=true;
                   }else if(lengTH==8){
                     vm.leng2=true;
                    vm.leng3=true;
                     vm.leng4=true;
                    vm.leng5=true;
                    vm.leng6=true;
                    vm.leng7=true;
                    vm.leng8=true;
                   }else if(lengTH==9){
                     vm.leng2=true;
                    vm.leng3=true;
                    vm.leng4=true;
                    vm.leng5=true;
                    vm.leng6=true;
                    vm.leng7=true;
                    vm.leng8=true;
                    vm.leng9=true;
                   }else if(lengTH==10){
                     vm.leng2=true;
                    vm.leng3=true;
                      vm.leng4=true;
                    vm.leng5=true;
                    vm.leng6=true;
                    vm.leng7=true;
                    vm.leng8=true;
                    vm.leng9=true;
                    vm.leng10=true;
                   }else if(lengTH==11){
                     vm.leng2=true;
                    vm.leng3=true;
                    vm.leng4=true;
                    vm.leng5=true;
                    vm.leng6=true;
                    vm.leng7=true;
                    vm.leng8=true;
                    vm.leng9=true;
                    vm.leng10=true;
                    vm.leng11=true;
                   }
                  
                  
                  // vm.$message.success({message:ret.msg});
                  // vm.onSubmit();
                }else{
                  vm.$message.error({message:ret.msg});
                  vm.leng1=false;
                    vm.leng2=false;
                    vm.leng3=false;
                    vm.leng4=false;
                    vm.leng5=false;
                    vm.leng6=false;
                    vm.leng7=false;
                    vm.leng8=false;
                    vm.leng9=false;
                    vm.leng10=false;
                    vm.leng11=false;
                }
            
            });
      },
      //分组周期变化
      cycBian(){
           var vm =this;
           http.postData(vm, '/pt/subjectsGroup/getInfo/'+vm.$utils.getCurrenrProject().id, {cycles:vm.cycle}, function (resp) {
              var ret = resp.body;
              // console.log(resp)
              if(ret.code == '111'){
                      vm.pointArr=ret.value.process;

                
              }else{
                vm.$message.error({message:ret.msg});
              }
            
            });
      },
      packetsub(){
          var vm =this;
         http.postData(vm, '/pt/subjectsGroup/groby', {json: JSON.stringify(vm.ids),proid:vm.pjcID,json2:JSON.stringify(vm.Arr2ren),time:vm.times,next:vm.timeInterval,group:vm.group,cycles:vm.cycle,sort_no:vm.point,medicine:vm.drugClass}, function (resp) {
              var ret = resp.body;
              //console.log(resp)
              if(ret.code == '111'){
                vm.$message.success({message:ret.msg});
                vm.onSubmit();
                vm.batchgrouping=false;
                vm.group='';
                vm.grouparr=[];
                vm.times=null;
                vm.timeInterval="";
                vm.cycle="";
                vm.pjcID="";
                vm.cycleArr=[];
                vm.drugClass="";
                vm.adminis='';
                vm.adminisArr=[];
                vm.adminisid=[];
                vm.pointArr=[];
                 vm.Arr2ren=[];
                vm.point='';

                
              }else{
                vm.$message.error({message:ret.msg});
              }
            
            });
      },
      handleSelectionChange(val) {
        this.multipleSelection = val
      },
       openNumDialogTable(row){
          this.sex = row.sex;
          this.subTime = row.passTime;
          this.name = row.name;
         this.subjectId = row.id;
          this.numDialog.show = true;
       },
      closeNumDialog(){
          this.numDialog.show = false;
      },
      openVisitDialogTable(row){
        this.subjectId = row.id;
        this.visitDialog.show = true;
      },
      closeVisitDialog(){
        this.visitDialog.show = false;
      },
      openTimeDialogTable(row){
        this.subjectId = row.id;
        this.subjectNum = row.num;
        this.projectId = row.projectId;
        this.timeDialog.show = true;
      },
      
      closeTimeDialogTable(){
        this.timeDialog.show = false
      },
      openTimeDialog(row){
        var vm = this;
        http.postData(vm, '/pt/process/queryProcessTimeLine/' + row.id+'-'+ this.$utils.getCurrenrProject().id, {}, function (resp) {
          var ret = resp.body;
          if (ret.code == '111') {
            vm.timeList = ret.value;
            vm.leng1=true;
                  vm.leng2=true;
                  vm.leng3=true;
            vm.leng4=false;
                vm.leng5=false;
                vm.leng6=false;
                vm.leng7=false;
                vm.leng8=false;
                vm.leng9=false;
                vm.leng10=false;
                vm.leng11=false;
                let lengTH=ret.value[0].length;
               if(lengTH==4){
                  vm.leng4=true;
               }else if(lengTH==5){
                vm.leng4=true;
                vm.leng5=true;
               }else if(lengTH==6){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
               }else if(lengTH==7){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
               }else if(lengTH==8){
                 vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
               }else if(lengTH==9){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
                vm.leng9=true;
               }else if(lengTH==10){
                  vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
                vm.leng9=true;
                vm.leng10=true;
               }else if(lengTH==11){
                vm.leng4=true;
                vm.leng5=true;
                vm.leng6=true;
                vm.leng7=true;
                vm.leng8=true;
                vm.leng9=true;
                vm.leng10=true;
                vm.leng11=true;
               }

          }
        })
      },
      openTagDialog(row) {
        this.subjectNum = row.num;
        this.subjectId = row.id;
        this.tagDialog.show = true
      },
      closeTagDialog() {
        this.subjectId = null;
        this.tagDialog.show = false
      },
      openRegisterDialog(id,status,finger) {
        this.currentSubjectId = id;
        this.currentHospitalStatus = status;
        this.currentFinger = finger;
        this.registerDialog.show = true
      },
      closeRegisterDialog() {
        this.registerDialog.show = false
      },
      onSubmit (sortCol) {
        var vm = this;
        if (sortCol && sortCol.prop != undefined && sortCol.prop != '' && sortCol.prop != 'undefined') {
          var sortJson = '{"' + sortCol.prop + '":"' + (sortCol.order == 'descending' ? 'desc' : 'asc') + '"}';
          vm.form.filter.sort = JSON.parse(sortJson);
          vm.form.pageNo = 1;
        }
        vm.loading = true;
        if (vm.$utils.getCurrenrProject().id == null) {
          vm.$notify({title: '操作提示', message: '请选择项目', type: 'error'});
          
        }

        http.postData(vm, "/pt/subjectsGroup/page/" + this.$utils.getCurrenrProject().id, {
          // json: JSON.stringify(vm.form.filter),
          // pageNo: vm.form.pageNo,
          // pageSize: vm.form.pageSize,
          cycles:'0'
        }, function (resp) {
          var ret = resp.body;
            // console.log(ret.value[0])
          
          if (ret.code == '111') {
            vm.page = ret.value[0];
            vm.cycleSelection=ret.value[1];
          }
          vm.loading = false;
        });
      },
      closeEditDialog() {
        this.editDialog.show = false;
      },
      openEditDialog(id_) {
        this.currentSubjectId = id_;
        this.editDialog.show = true;
      },
     
      handleSizeChange () {
        this.form.pageNo = 1
        this.onSubmit()
      },
      handleCurrentChange (val) {
        this.form.pageNo = val
        this.onSubmit()
      },
      dicTransfor(){
        var vm =this;
        var thiscyc="";
        if(vm.cycleSee=="筛选池"){
          thiscyc="0";
          vm.fenzu=true;
          vm.zufen=false;

        }else{
          thiscyc=vm.cycleSee;
          vm.zufen=true;
          vm.fenzu=false;

        }
        vm.loading = true;
        if (vm.$utils.getCurrenrProject().id == null) {
          vm.$notify({title: '操作提示', message: '请选择项目', type: 'error'});
          
        }
        
        http.postData(vm, "/pt/subjectsGroup/page/" + this.$utils.getCurrenrProject().id, {cycles:thiscyc}, function (resp) {
          var ret = resp.body;
            // console.log(ret.value[0])
          
          if (ret.code == '111') {
            vm.page = ret.value[0];
            vm.cycleSelection=ret.value[1];
          }
          vm.loading = false;
        });

      },
      //打印按钮
      printing(){
        var vm=this;
        http.postData(vm, '/pt/subjectsGroup/plantable2', {projectId:vm.pjcID,group:vm.group2,type:vm.timeA,cycles:vm.cycleSee}, function (resp) {
            var ret = resp.body;
            if (ret.code == 111) {
              // console.log(ret.value)
              vm.itmeList=ret.value;
              setTimeout(function () {
                var printHtml = vm.$el.querySelector("#printTarget").innerHTML;
                var wid = window.open('blank', '_blank', 'width=200px;');
                wid.document.write(printHtml);
                setTimeout(function () {
                  wid.print();
                  wid.close();
                }, 1000);
              }, 500);
            }
          })
      },
      fallOff(id){
        var vm=this;
        
        vm.causefallingID=id;
        vm.causefalling=true;
        http.postData(vm, '/pt/subjectsGroup/dropOneMsg', {projectid:vm.$utils.getCurrenrProject().id,id:vm.causefallingID}, function (resp) {
            var ret = resp.body;
            if (ret.code == 111) {
              vm.causefallingUnknown=ret.msg;
              vm.causefallingArr=ret.value;
            }else{
              vm.$message.error({message:ret.msg});
            }
          })
      },
      causesub(){
        //脱落确定按钮
        var vm=this;
        
        
        if(vm.causefallcycle=="未开始"){
          var tuoluo=0;
        }else{
          var tuoluo=vm.causefallcycle;
        }
        http.postData(vm, '/pt/subjectsGroup/dropOne', {id:vm.causefallingID,drop:vm.falling,time:vm.causetime,cycles:tuoluo}, function (resp) {
            var ret = resp.body;
            // console.log(resp)
            if (ret.code == 111) {
              vm.$message.success({message:ret.msg});
              vm.onSubmit();
              vm.causefalling=false;
              vm.causefallingID='';
              vm.falling='';
              vm.causetime='';
              vm.causefallcycle="";
            }else{
              vm.$message.error({message:ret.msg});
            }
          })
      },
      causefallingcols(){
        //脱落取消按钮
        var vm=this;
        vm.causefalling=false;
        vm.causefallingID='';
        vm.falling='';
        vm.causetime='';
        vm.causefallcycle="";
        
      }
    },
    
    components: {
      // EditDialog,
      // RegisterDialog,
      // TagDialog,
      // TimeDialog,
//      VisitDialog,
//      NumDialog
    },
    created() {
      this.onSubmit();
      var vm = this;
      http.postData(vm,'/pt/project/detail/' + vm.$utils.getCurrenrProject().id,{},function (resp) {
        var ret = resp.body;
        if(ret.code == 111){
          vm.currentStatus = ret.value.status;
        };
      });
    }
  }

</script>
<style>
 
  .sstime .el-date-editor--datetime .el-input__inner{
      width:180px;
      padding: 5px;
  }
  .sstime .el-icon-time{
    right: -10px;
  }
  .Fzu{
    float:left;
    margin-right: 20px;

  }
  .sstime{
    margin:50px 0 0 0 ;
  }
  .upVVV .el-dialog--small{
    width:80%;

  }
  .el-dialog__body{
    padding: 10px 20px 25px 20px;
  }
  .fzuss{
    margin: 10px 0;
  }
.usefal{
  margin: 30px 0 20px 0;
}
.usefal2{
  margin: 20px 0 30px 0;
}
.usefal .el-date-editor--datetime .el-input__inner{
  width:170px;
  padding: 2px;
}
.guanli{
  margin-top: 20px;
}
.reds{
  color:red;
}
</style>
